package initialize

import (
	"github.com/elastic/go-elasticsearch/v7"
	"github.com/pkg/errors"
	"github.com/zeromicro/go-zero/core/logx"
)

// DBConn Db数据库连接池
//var DBConn *gorm.DB

func ESinit(esURL string) *elasticsearch.Client {
	cfg := elasticsearch.Config{
		Addresses: []string{esURL},
	}

	client, err := elasticsearch.NewClient(cfg)
	if err != nil {
		logx.Error(errors.Wrapf(err, "casbin LoadPolicy error"))
		return nil
	}

	return client
}
